// 将嵌套路由扁平化
const testCase = [
    {
        path: '/jobs',
        routes: [
            {
                path: '/auto_create',
            },
            {
                path: '/:jobId',
                routes: [{
                    path: '/info',
                },
                {
                    path: '/satisfaction',
                    routes: [{
                        path: ['/pandect/:candidateId', '/application/:applicationId', '/:id'],
                    }]
                }
                ]
            }
        ]
    },
    {
        path: '/heat_preservation',
        routes: [{
            path: '/interview',
        },
        {
            path: '/offer',
        },
        ]
    },
    {
        path: '/csc',
        routes: [{
            path: '/interview',
        },
        {
            path: '/offer',
        },
        ]
    }
];

const flat = (arr) => {
    const res = []
    const dfs = (arr, str) => {
    arr.forEach(item => {
        if(!item.routes) {
            if(item.path instanceof Array) {
                item.path.forEach(item => {
                    res.push(str+item)
                })
                return
            }
            return res.push(str+item.path)
        }
        else {
            dfs(item.routes, str+item.path)
        }
    })
    }
    dfs(arr, '')
    console.log(res);
    return res
}
console.log(flat(testCase));